﻿@using Website.CRUDServices
@using Website.Models.Styling
@model Website.Models.ViewModels.AdminUserView
@{
    this.ViewBag.Title = "UserView";
    this.Layout = "~/Views/_Shared/_Layout.cshtml";
}


@if (this.Model.UserList != null)
{
    <!--table of users:
        name | username | mail | phonenumber | edit button -->

    <table class="tableView">
        <tr>
            @foreach (TableViewHeaderItem item in this.Model.TableHeader.Items)
            {
                <td>
                    @Html.Partial("~/Views/_Shared/TableViewHeader.cshtml", item)
                </td>
            }<td><!--Empty to make space for edit column--></td>
        </tr>
        @foreach (User user in this.Model.UserList)
        {
            <tr>
                <td>@user.Name </td>
                <td>@user.Username</td>
                <td>@user.Email </td>
                <td>@user.PhoneNumber </td>
                <td><a href="@Url.Action("EditUser", new { @Id = user.ID })"><img src="@Url.Content("~/Content/ButtonIcons/tool_blue.png")" alt="Link"/></a></td>
            </tr>
        }
    
        <!-- Navigation arrows. -->
        <tr>
            @Html.Partial("~/Views/_Shared/PagingArrows.cshtml", new PagingArrows { Action = "UserView", TotalAmountOfColumns = 5, CurrentSkip = this.Model.Skip, CurrentTake = this.Model.Take, CurrentTotalRowCount = this.Model.TotalUsers })
        </tr>
    </table>
}
else
{
    <div class="error">FEJL! Brugerlisten er tom.</div>
}